extends CharacterBody2D

@export var movement_speed = 20.0
@export var hp = 10

@onready var player = get_tree().get_first_node_in_group("player")
@onready var enemySprite = $Sprite2D
@onready var animation = $AnimationPlayer

func _ready():
	print("胡汉三来了")
	animation.play("walk")


func _process(_delta):
	var direction = global_position.direction_to(player.global_position)
	self.velocity = direction * movement_speed

	if direction.x > 0:
		enemySprite.flip_h = true
	elif direction.x < 0:
		enemySprite.flip_h = false
	move_and_slide()
